package com.zhou.service;

import com.zhou.dao.UserDAO;
import com.zhou.entity.Perms;
import com.zhou.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDAO userDAO;


    @Override
    public void register(User user) {
        userDAO.save(user);
    }

    @Override
    public User login(String account, String password) {
        User login = userDAO.login(account, password);

        return login;
    }

    /**根据用户名查询业务的方法*/
    @Override
    public User findByUserName(String account) {
        return userDAO.findByUserName(account);
    }

    @Override
    public User findRoleByUserName(String account) {
        return userDAO.findRoleByUserName(account);
    }

    @Override
    public List<Perms> findPermsByRoleId(int id) {
        return userDAO.findPermsByRoleId(id);
    }

}
